rmdir.js ➔ ... ➔ ???   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 2
c 1
b 1
f 1
nc 2
nop 1
dl 0
loc 8
rs 9.4285
1
import fs from 'fs'
2
3
const deleteFolderRecursive = path => {
4
  if (fs.existsSync(path)) {
5
    fs.readdirSync(path).forEach((file) => {
6
      const curPath = `${path}/${file}`
7
      if (fs.lstatSync(curPath).isDirectory()) {
8
        deleteFolderRecursive(curPath)
9
      } else {
10
        fs.unlinkSync(curPath)
11
      }
12
    })
13
    fs.rmdirSync(path)
14
  }
15
}
16
17
export default deleteFolderRecursive